/**
 * ts文件不能引入组件只能配置项，需要引入组件改为tsx文件
 */
import { RunTimeLayoutConfig, SelectLang } from '@umijs/max';
import HeaderDropDown from './components/HeaderDropDown';
import { requestConfig } from './utils/request';

// 全局初始化数据配置，用于 Layout 用户信息和权限初始化
// 更多信息见文档：https://umijs.org/docs/api/runtime-config#getinitialstate
export async function getInitialState(): Promise<{ name: string }> {
  return { name: '@umijs/max' };
}

export const layout: RunTimeLayoutConfig = () => {
  return {
    logo: 'https://img.alicdn.com/tfs/TB1YHEpwUT1gK0jSZFhXXaAtVXa-28-27.svg',
    layout: 'mix',
    splitMenus: false,
    menu: {
      locale: false,
    },
    actionsRender: () => [<SelectLang key="SelectLang" reload={false} />],
    avatarProps: {
      src: 'http://localhost:3000/uploads/80232e142737f30e0b55fe985d95d0de',
      title: '',
      render: (_: any, avatarChildren: any) => {
        return <HeaderDropDown>{avatarChildren}</HeaderDropDown>;
      },
    },
    // footerRender: () => <>1</>,
    // rootContainer: (container: any, args: any) => {
    //   return <App>{container}</App>;
    // },
  };
};

export const request = {
  ...requestConfig,
};
